// polymorphism
// private members
// public members
// interface (virtual member function)
// object java.lang.Object
// defineProperty enumerable

var o = new Object();
console.log(o.prototype);
var f = new Function();
console.log(f.__proto__);


//
var BaseCalculator = function() {

};

BaseCalculator.prototype = {
    add: function(x, y) {
        return x + y;
    },
    subtract: function(x, y) {
        return x - y;
    }
};

var Calculator = function () {


};

Calculator.prototype = new BaseCalculator();
var c = new Calculator();
//console.log(Calculator.add(5,8));

console.log(c.add(5,8));
console.log(Calculator.__proto__.name);
console.log(Calculator.prototype.name);


/*
testify the following
__proto__ is the actual object that is used in the lookup chain to resolve methods, etc. prototype is the object that is used to build __proto__ when you create an object with new:

( new Foo ).__proto__ === Foo.prototype
( new Foo ).prototype === undefined
*/

/*
members'  advanced definition
Object.defineProperty(obj, prop, descriptor)
Parameters

obj
The object on which to define the property.
prop
The name of the property to be defined or modified.
descriptor
The descriptor for the property being defined or modified.
Return value

The object that was passed to the function.

descriptor:
configurable
true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.
Defaults to false.
enumerable
true if and only if this property shows up during enumeration of the properties on the corresponding object.
Defaults to false.
A data descriptor also has the following optional keys:

value
The value associated with the property. Can be any valid JavaScript value (number, object, function, etc).
Defaults to undefined.
writable
true if and only if the value associated with the property may be changed with an assignment operator.
Defaults to false.
An accessor descriptor also has the following optional keys:

get
A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property.
Defaults to undefined.
set
A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property.
Defaults to undefined.

*/
